<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<%@ page import="java.util.*,util.*,dal.*,model.*,bll.*"%>
<%
	QuotationItemModel obj;
	Object temp = request.getAttribute("quotationitem");
	if (temp != null) {
		try {
			obj = (QuotationItemModel) temp;
		} catch (Exception ex) {
			obj = new QuotationItemModel();
		}
	} else {
		obj = new QuotationItemModel();
	}
%>

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Create New Quotation Item</title>
<script language="javascript" type="text/javascript"
	src="js/datepicker.js"></script>
<link rel="stylesheet" href="css/datepicker.css" />
<link rel="stylesheet" href="css/common.css" />
<link rel="stylesheet" href="css/jquery-ui-1.8.14.custom.css"
	type="text/css" />
<link rel="stylesheet" href="css/jquery-ui-timepicker.css"
	type="text/css" />

<script language="javascript" type="text/javascript" src="js/common.js"></script>
<script language="javascript" type="text/javascript"
	src="js/jquery.min.js"></script>
<script src="js/jquery-1.5.1.min.js" type="text/javascript"
	language="javascript"></script>
<script src="js/jquery.hyjack.select.js" type="text/javascript"
	language="javascript"></script>
<script type="text/javascript" src="js/jquery.ui.core.min.js"></script>
<script type="text/javascript" src="js/jquery.ui.widget.min.js"></script>

<script type="text/javascript" src="js/jquery.ui.timepicker.js"></script>

<script src="js/jquery.hyjack.js" type="text/javascript"
	language="javascript"></script>
<link rel="stylesheet" href="css/hyjack.css" type="text/css" />


<script language="javascript" type="text/javascript">
	var requiredInputs = [['id_parent','id_parent_required'],['code','code_required'],['name','name_required'],['description','description_required'],['remark','remark_required'],['index','index_required'],['display_index','display_index_required'],['id_product','id_product_required'],['id_service','id_service_required'],['id_unit','id_unit_required'],['id_currency','id_currency_required'],['estimate_quantity','estimate_quantity_required'],['quotation_quantity','quotation_quantity_required'],['internal_quantity','internal_quantity_required'],['estimate_unit_cost','estimate_unit_cost_required'],['quotation_unit_cost','quotation_unit_cost_required'],['internal_unit_cost','internal_unit_cost_required'],['estimate_total_amount','estimate_total_amount_required'],['quotation_total_amount','quotation_total_amount_required'],['internal_total_amount','internal_total_amount_required'],['id_type','id_type_required'],['status','status_required'],['notification','notification_required']];
	var intInputs = [['id_quotation','id_quotation_invalid'],['id_parent','id_parent_invalid'],['index','index_invalid'],['id_product','id_product_invalid'],['id_service','id_service_invalid'],['id_unit','id_unit_invalid'],['id_currency','id_currency_invalid'],['estimate_quantity','estimate_quantity_invalid'],['quotation_quantity','quotation_quantity_invalid'],['internal_quantity','internal_quantity_invalid'],['id_type','id_type_invalid'],['status','status_invalid'],['notification','notification_invalid']];
	var doubleInputs = [['estimate_unit_cost','estimate_unit_cost_invalid'],['quotation_unit_cost','quotation_unit_cost_invalid'],['internal_unit_cost','internal_unit_cost_invalid'],['estimate_total_amount','estimate_total_amount_invalid'],['quotation_total_amount','quotation_total_amount_invalid'],['internal_total_amount','internal_total_amount_invalid']];
	var dateInputs = [];
	var timeInputs = [];

	function checkInputs() {
		var valid = true;

		if (checkRequiredInputs(requiredInputs) == false) {
			valid = false;
		}
		if (checkIntInputs(intInputs) == false) {
			valid = false;
		}
		if (checkDoubleInputs(doubleInputs) == false) {
			valid = false;
		}
		if (checkDateInputs(dateInputs) == false) {
			valid = false;
		}
		if (checkTimeInputs(timeInputs) == false) {
			valid = false;
		}

		// SPECIFIC VALIDATE CODE HERE		

		return valid;
	}
</script>
</head>
<body>
     <%@ include file="menu.jsp"%>
	<br />
    <table>
		<tr>
			<td>
	            <form action="quotationitem?mode=insert" method="post"
                    onSubmit="return checkInputs()"
                    onreset="return confirm('Do you really want to reset the form?')">
		            <table class="tblInput" border="1">
			            <tr class="inputHeader">
				            <th colspan="3" class="inputHeader">Create New Quotation Item</th>
			            </tr>
            			<tr class="trField">
				<td class="tdFieldName">Id Quotation</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_quotation" name="id_quotation" maxlength="10" value="<%=obj.getIdQuotation()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_quotation_required" class="errMsg" style="display: none;">Id Quotation is required</span> 
					<span id="id_quotation_invalid" class="errMsg" style="display: none;">Id Quotation is invalid</span>
                    <span id="id_quotation_error" class="errMsg"><%=obj.errMsgs.IdQuotation%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Parent</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_parent" name="id_parent" maxlength="10" value="<%=obj.getIdParent()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_parent_required" class="errMsg" style="display: none;">Id Parent is required</span> 
					<span id="id_parent_invalid" class="errMsg" style="display: none;">Id Parent is invalid</span>
                    <span id="id_parent_error" class="errMsg"><%=obj.errMsgs.IdParent%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Code</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="code" name="code" maxlength="20" value="<%=obj.getCode()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="code_required" class="errMsg" style="display: none;">Code is required</span>
					<span id="code_invalid" class="errMsg" style="display: none;">Code is invalid</span>
                    <span id="code_error" class="errMsg"><%=obj.errMsgs.Code%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Name</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="name" name="name" maxlength="255" value="<%=obj.getName()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="name_required" class="errMsg" style="display: none;">Name is required</span>
					<span id="name_invalid" class="errMsg" style="display: none;">Name is invalid</span>
                    <span id="name_error" class="errMsg"><%=obj.errMsgs.Name%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Description</td>				    <td class="tdFieldInput">
					<textarea id="description" name="description" rows="5" class="inputTextarea"><%=obj.getDescription()%></textarea>
				</td>
				<td class="tdErrMsg">
					<span id="description_required" class="errMsg" style="display: none;">Description is required</span>
					<span id="description_invalid" class="errMsg" style="display: none;">Description is invalid</span>
                    <span id="description_error" class="errMsg"><%=obj.errMsgs.Description%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Remark</td>				    <td class="tdFieldInput">
					<textarea id="remark" name="remark" rows="5" class="inputTextarea"><%=obj.getRemark()%></textarea>
				</td>
				<td class="tdErrMsg">
					<span id="remark_required" class="errMsg" style="display: none;">Remark is required</span>
					<span id="remark_invalid" class="errMsg" style="display: none;">Remark is invalid</span>
                    <span id="remark_error" class="errMsg"><%=obj.errMsgs.Remark%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Is Group</td><td class="tdFieldInput">
					<table class="tblBool">
						<tr class="trBoolSet">
							<td colspan="2" class="tdBoolSet"><input type="checkbox"
								id="ckb_is_group" name="ckb_is_group"
								onchange="toggleControls(['is_group_true', 'is_group_false'])" />Not
								set</td>
						</tr>
						<tr class="trBool">
							<td class="tdBool"><input type="radio"
								id="is_group_true" name="is_group" value="1"
								checked="checked" />Yes</td>
							<td class="tdBool"><input type="radio"
								id="is_group_false" name="is_group" value="0" />No</td>
						</tr>
					</table></td>
				<td class="tdErrMsg"></td></tr>
			<tr class="trField">
				<td class="tdFieldName">Index</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="index" name="index" maxlength="10" value="<%=obj.getIndex()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="index_required" class="errMsg" style="display: none;">Index is required</span> 
					<span id="index_invalid" class="errMsg" style="display: none;">Index is invalid</span>
                    <span id="index_error" class="errMsg"><%=obj.errMsgs.Index%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Display Index</td>			    <td class="tdFieldInput">
					<input class="inputText" type="text" id="display_index" name="display_index" maxlength="10" value="<%=obj.getDisplayIndex()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="display_index_required" class="errMsg" style="display: none;">Display Index is required</span>
					<span id="display_index_invalid" class="errMsg" style="display: none;">Display Index is invalid</span>
                    <span id="display_index_error" class="errMsg"><%=obj.errMsgs.DisplayIndex%></span>
				</td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Product</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_product" name="id_product" maxlength="10" value="<%=obj.getIdProduct()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_product_required" class="errMsg" style="display: none;">Id Product is required</span> 
					<span id="id_product_invalid" class="errMsg" style="display: none;">Id Product is invalid</span>
                    <span id="id_product_error" class="errMsg"><%=obj.errMsgs.IdProduct%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Service</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_service" name="id_service" maxlength="10" value="<%=obj.getIdService()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_service_required" class="errMsg" style="display: none;">Id Service is required</span> 
					<span id="id_service_invalid" class="errMsg" style="display: none;">Id Service is invalid</span>
                    <span id="id_service_error" class="errMsg"><%=obj.errMsgs.IdService%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Unit</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_unit" name="id_unit" maxlength="10" value="<%=obj.getIdUnit()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_unit_required" class="errMsg" style="display: none;">Id Unit is required</span> 
					<span id="id_unit_invalid" class="errMsg" style="display: none;">Id Unit is invalid</span>
                    <span id="id_unit_error" class="errMsg"><%=obj.errMsgs.IdUnit%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Currency</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_currency" name="id_currency" maxlength="10" value="<%=obj.getIdCurrency()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_currency_required" class="errMsg" style="display: none;">Id Currency is required</span> 
					<span id="id_currency_invalid" class="errMsg" style="display: none;">Id Currency is invalid</span>
                    <span id="id_currency_error" class="errMsg"><%=obj.errMsgs.IdCurrency%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Estimate Quantity</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="estimate_quantity" name="estimate_quantity" maxlength="10" value="<%=obj.getEstimateQuantity()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="estimate_quantity_required" class="errMsg" style="display: none;">Estimate Quantity is required</span> 
					<span id="estimate_quantity_invalid" class="errMsg" style="display: none;">Estimate Quantity is invalid</span>
                    <span id="estimate_quantity_error" class="errMsg"><%=obj.errMsgs.EstimateQuantity%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Quotation Quantity</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="quotation_quantity" name="quotation_quantity" maxlength="10" value="<%=obj.getQuotationQuantity()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="quotation_quantity_required" class="errMsg" style="display: none;">Quotation Quantity is required</span> 
					<span id="quotation_quantity_invalid" class="errMsg" style="display: none;">Quotation Quantity is invalid</span>
                    <span id="quotation_quantity_error" class="errMsg"><%=obj.errMsgs.QuotationQuantity%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Internal Quantity</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="internal_quantity" name="internal_quantity" maxlength="10" value="<%=obj.getInternalQuantity()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="internal_quantity_required" class="errMsg" style="display: none;">Internal Quantity is required</span> 
					<span id="internal_quantity_invalid" class="errMsg" style="display: none;">Internal Quantity is invalid</span>
                    <span id="internal_quantity_error" class="errMsg"><%=obj.errMsgs.InternalQuantity%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Estimate Unit Cost</td>				<td class="tdFieldInput">
					<input class="inputNumeric" type="text" id="estimate_unit_cost" name="estimate_unit_cost" maxlength="20" value="<%=obj.getEstimateUnitCost()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="estimate_unit_cost_required" class="errMsg" style="display: none;">Estimate Unit Cost is required</span> 
					<span id="estimate_unit_cost_invalid" class="errMsg" style="display: none;">Estimate Unit Cost is invalid</span>
                    <span id="estimate_unit_cost_error" class="errMsg"><%=obj.errMsgs.EstimateUnitCost%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Quotation Unit Cost</td>				<td class="tdFieldInput">
					<input class="inputNumeric" type="text" id="quotation_unit_cost" name="quotation_unit_cost" maxlength="20" value="<%=obj.getQuotationUnitCost()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="quotation_unit_cost_required" class="errMsg" style="display: none;">Quotation Unit Cost is required</span> 
					<span id="quotation_unit_cost_invalid" class="errMsg" style="display: none;">Quotation Unit Cost is invalid</span>
                    <span id="quotation_unit_cost_error" class="errMsg"><%=obj.errMsgs.QuotationUnitCost%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Internal Unit Cost</td>				<td class="tdFieldInput">
					<input class="inputNumeric" type="text" id="internal_unit_cost" name="internal_unit_cost" maxlength="20" value="<%=obj.getInternalUnitCost()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="internal_unit_cost_required" class="errMsg" style="display: none;">Internal Unit Cost is required</span> 
					<span id="internal_unit_cost_invalid" class="errMsg" style="display: none;">Internal Unit Cost is invalid</span>
                    <span id="internal_unit_cost_error" class="errMsg"><%=obj.errMsgs.InternalUnitCost%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Estimate Total Amount</td>				<td class="tdFieldInput">
					<input class="inputNumeric" type="text" id="estimate_total_amount" name="estimate_total_amount" maxlength="20" value="<%=obj.getEstimateTotalAmount()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="estimate_total_amount_required" class="errMsg" style="display: none;">Estimate Total Amount is required</span> 
					<span id="estimate_total_amount_invalid" class="errMsg" style="display: none;">Estimate Total Amount is invalid</span>
                    <span id="estimate_total_amount_error" class="errMsg"><%=obj.errMsgs.EstimateTotalAmount%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Quotation Total Amount</td>				<td class="tdFieldInput">
					<input class="inputNumeric" type="text" id="quotation_total_amount" name="quotation_total_amount" maxlength="20" value="<%=obj.getQuotationTotalAmount()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="quotation_total_amount_required" class="errMsg" style="display: none;">Quotation Total Amount is required</span> 
					<span id="quotation_total_amount_invalid" class="errMsg" style="display: none;">Quotation Total Amount is invalid</span>
                    <span id="quotation_total_amount_error" class="errMsg"><%=obj.errMsgs.QuotationTotalAmount%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Internal Total Amount</td>				<td class="tdFieldInput">
					<input class="inputNumeric" type="text" id="internal_total_amount" name="internal_total_amount" maxlength="20" value="<%=obj.getInternalTotalAmount()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="internal_total_amount_required" class="errMsg" style="display: none;">Internal Total Amount is required</span> 
					<span id="internal_total_amount_invalid" class="errMsg" style="display: none;">Internal Total Amount is invalid</span>
                    <span id="internal_total_amount_error" class="errMsg"><%=obj.errMsgs.InternalTotalAmount%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">In Estimate</td><td class="tdFieldInput">
					<table class="tblBool">
						<tr class="trBoolSet">
							<td colspan="2" class="tdBoolSet"><input type="checkbox"
								id="ckb_in_estimate" name="ckb_in_estimate"
								onchange="toggleControls(['in_estimate_true', 'in_estimate_false'])" />Not
								set</td>
						</tr>
						<tr class="trBool">
							<td class="tdBool"><input type="radio"
								id="in_estimate_true" name="in_estimate" value="1"
								checked="checked" />Yes</td>
							<td class="tdBool"><input type="radio"
								id="in_estimate_false" name="in_estimate" value="0" />No</td>
						</tr>
					</table></td>
				<td class="tdErrMsg"></td></tr>
			<tr class="trField">
				<td class="tdFieldName">In Quotation</td><td class="tdFieldInput">
					<table class="tblBool">
						<tr class="trBoolSet">
							<td colspan="2" class="tdBoolSet"><input type="checkbox"
								id="ckb_in_quotation" name="ckb_in_quotation"
								onchange="toggleControls(['in_quotation_true', 'in_quotation_false'])" />Not
								set</td>
						</tr>
						<tr class="trBool">
							<td class="tdBool"><input type="radio"
								id="in_quotation_true" name="in_quotation" value="1"
								checked="checked" />Yes</td>
							<td class="tdBool"><input type="radio"
								id="in_quotation_false" name="in_quotation" value="0" />No</td>
						</tr>
					</table></td>
				<td class="tdErrMsg"></td></tr>
			<tr class="trField">
				<td class="tdFieldName">In Internal</td><td class="tdFieldInput">
					<table class="tblBool">
						<tr class="trBoolSet">
							<td colspan="2" class="tdBoolSet"><input type="checkbox"
								id="ckb_in_internal" name="ckb_in_internal"
								onchange="toggleControls(['in_internal_true', 'in_internal_false'])" />Not
								set</td>
						</tr>
						<tr class="trBool">
							<td class="tdBool"><input type="radio"
								id="in_internal_true" name="in_internal" value="1"
								checked="checked" />Yes</td>
							<td class="tdBool"><input type="radio"
								id="in_internal_false" name="in_internal" value="0" />No</td>
						</tr>
					</table></td>
				<td class="tdErrMsg"></td></tr>
			<tr class="trField">
				<td class="tdFieldName">Id Type</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="id_type" name="id_type" maxlength="10" value="<%=obj.getIdType()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="id_type_required" class="errMsg" style="display: none;">Id Type is required</span> 
					<span id="id_type_invalid" class="errMsg" style="display: none;">Id Type is invalid</span>
                    <span id="id_type_error" class="errMsg"><%=obj.errMsgs.IdType%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Status</td>				<td class="tdFieldInput">
					<select id="status" name="status" class="dropdownlistStyle">
									<%=HtmlUtil.genEnumSelect(EnumName.QuotationItemStatus, null, obj.getStatus())%>
					</select>
				</td>
				<td class="tdErrMsg">
					<span id="status_required" class="errMsg" style="display: none;">Status is required</span> 
					<span id="status_invalid" class="errMsg" style="display: none;">Status is invalid</span>
                    <span id="status_error" class="errMsg"><%=obj.errMsgs.Status%></span>
                </td></tr>
			<tr class="trField">
				<td class="tdFieldName">Notification</td>				<td class="tdFieldInput">
					<input class="inputInt" type="text" id="notification" name="notification" maxlength="10" value="<%=obj.getNotification()%>" />
				</td>
				<td class="tdErrMsg">
					<span id="notification_required" class="errMsg" style="display: none;">Notification is required</span> 
					<span id="notification_invalid" class="errMsg" style="display: none;">Notification is invalid</span>
                    <span id="notification_error" class="errMsg"><%=obj.errMsgs.Notification%></span>
                </td></tr>
			
			            <tr class="trInputBottom">
				            <td class="tdInputBottom" colspan="3">
					            <table class="tblSubmit" align="center">
						            <tr class="trSubmit">
							            <td class="tdSubmit"><input type="submit" value="Submit" />
							            </td>
							            <td class="tdReset"><input type="reset" value="Reset" /></td>
						            </tr>
					            </table></td>
			            </tr>
		            </table>
	            </form>
            </td>
		</tr>
	</table>
    <br />
	<jsp:include page="quotationItemList.jsp?embedded=true"></jsp:include>
</body>
</html>